package com.gaming.glb;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;

public class MainScreen extends Activity implements OnClickListener {
	private static final String TAG = "Game Test" ;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	super.onCreate(savedInstanceState);
    	setContentView(R.layout.main);
    	
    	// Set up click listeners for all the buttons
    	View continueButton = findViewById(R.id.settings_button);
    	continueButton.setOnClickListener(this);
    	View newButton = findViewById(R.id.new_button);
    	newButton.setOnClickListener(this);
    	View aboutButton = findViewById(R.id.about_button);
    	aboutButton.setOnClickListener(this);
    	View exitButton = findViewById(R.id.exit_button);
    	exitButton.setOnClickListener(this);
    }
    
    public void onClick(View v) {
    	switch (v.getId()) {
    	case R.id.settings_button:
	    	Intent g = new Intent(this, Prefs.class);
	    	startActivity(g);
	    	break;
    	case R.id.about_button:
	    	Intent i = new Intent(this, About.class);
	    	startActivity(i);
	    	break;
    	case R.id.exit_button:
    		finish();
    		break;
    	case R.id.new_button:
    		openLevelSelector();
    		break;
    	}
    }
    
        
    private void openLevelSelector() {
    	Intent g = new Intent(this, LevelSelector.class);
    	startActivity(g);
    }
    
    private void openNewGameDialog() {
    	new AlertDialog.Builder(this)
    		.setTitle(R.string.new_game_title)
    		.setItems(R.array.difficulty,
    		new DialogInterface.OnClickListener() {
    			public void onClick(DialogInterface dialoginterface,
    					int i) {
    				startGame(i);
    			}
    		})
    		.show();
    }
    
    private void startGame(int i) {
    	Log.d(TAG, "clicked on " + i);
    	// Start game here...
    	Intent g = new Intent(this, MainActivity.class);
    	startActivity(g);
    }
    	
}